<template>
	<view class="container">
		<view class="detail">
			<view class="detail_top">
				<image class="detail_top_left" v-if="bookID === '2001'" src="http://ceshi.dishait.cn/ceshiData/Rebook/Rebook1.jpg"></image>
				<image class="detail_top_left" v-if="bookID !== '2001'" :src="bookDetail.imgurl"></image>
				<view class="detail_top_right"></view>
			</view>
		</view>
	</view>
</template>

<script>
	import TestSynopsis from "@/model/testSynopsis.js"
	import Book from "@/model/book.js"
	export default {
		data() {
			return {
				bookID : '',
				chapterCatalog: [],
				bookDetail: {},
				testSynopsis: {},
				bookList: [],
			}
		},
		async onLoad(options) {
			this.bookID = options.bookID
			// console.log(this.bookID)
			await this.getTestSynopsis();
			await this.getBookList();
			await this.getBookDetail();
		},
		methods: {
			async getTestSynopsis(){
				const res = await TestSynopsis.getTestSynopsis();
				this.chapterCatalog = res.chapterCatalog
				this.testSynopsis = res
				// console.log(this.testSynopsis)
			},
			async getBookList(){
				const res = await Book.getBookList();
				this.bookList = res.list
				// console.log(this.bookList)
			},
			getBookDetail(){
				if(this.bookID === "2001"){
					this.bookDetail = this.testSynopsis
					console.log(this.bookDetail)
				}else{
					const bookDetail = this.bookList.filter((item)=> item.id === Number(this.bookID))
					console.log(bookDetail)
				}
			}
		}
	}
</script>

<style scoped>
.container{
	width: 100%;
}
.detail{
	width: 100%;
}
.detail_top{
	width: 100%;
	padding: 30rpx 20rpx;
	background-color: #a8b0c3;
}
.detail_top_left{
	width: 230rpx;
	height: 210rpx;
}
</style>
